package com.cd.song.api.impl;

import com.cd.song.api.SongTagRelationService;
import com.cd.song.jpa.domain.SongTagRelation;
import com.cd.song.jpa.repo.SongTagRelationRepo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Optional;

@Service
public class SongTagRelationServiceImpl implements SongTagRelationService {

    @Autowired
    private SongTagRelationRepo songTagRelationRepository;

    @Override
    public List<SongTagRelation> findAll() {
        return songTagRelationRepository.findAll();
    }

    @Override
    public List<SongTagRelation> findByTagId(Long tagId) {
        return songTagRelationRepository.findByTagId(tagId);
    }

    @Override
    public SongTagRelation save(SongTagRelation relation) {
        return songTagRelationRepository.save(relation);
    }

    @Override
    public void deleteBySongIdAndTagId(Long songId, Long tagId) {
        songTagRelationRepository.deleteBySongIdAndTagId(songId, tagId);
    }

    @Override
    public Optional<SongTagRelation> findBySongIdAndTagId(Long songId, Long tagId) {
        return songTagRelationRepository.findBySongIdAndTagId(songId, tagId);
    }
}